POKE Statement ---------------------------------------------------------------------------- Action Writes a byte value into a specified memory location. Syntax POKE address, byte% Remarks The POKE statement uses the following arguments. ----------------------------------------------------------------------------- Argument Description ---------------------------------------------------------------------------- address An offset into the memory segment specified by the current default segment (as set by the DEF SEG Argument Description ---------------------------------------------------------------------------- segment (as set by the DEF SEG statement). The value of address is between 0 and 65,535, inclusive. byte% The data byte to be written into the memory location. The argument byte% is an integer value between 0 and 255, inclusive. Any value for byte% that must be represented in more than one byte (for instance, a long integer or any real number) is accepted; however, only the low order byte is used. The value of any high order bytes is ignored. If address is a single- or double-precision floating-point value, or a long integer, it is converted to a 2-byte integer. The POKE statement complements the PEEK function. Before using POKE to directly manipulate data stored in far memory, use the DEF SEG statement to set the current segment address. For example. DEF SEG = SSEG(a$)' Set current segment address to address of a$. Offset1 = SADD(a$)' Determine string's location within the segment. ' Write the byte stored in. POKE Offset1, PEEK(Offset2) Note BASIC moves string locations during run time. Therefore, the DEF SEG statement must be executed immediately before using the POKE statement. POKE and Expanded Memory Arrays Do not use POKE to manipulate expanded memory arrays. If you start QBX with the -Ea switch, any of these arrays may be stored in expanded memory. - Numeric arrays less than 16K in size. - Fixed-length string arrays less than 16K in size. - User-defined-type arrays less than 16K in size. If you want to use POKE to manipulate an array, first start QBX without the -Ea switch. (Without the -Ea switch, no arrays are stored in expanded memory.) For more information on using expanded memory, see "Memory Management for QBX" in Getting Started. Any address referred to by POKE in OS-2 protected mode must be open for writing. If POKE refers to a memory address for which your process does not have write permission, the operating system may generate a protection exception, or BASIC may generate the error message Permission denied. Warning Use POKE carefully. If used incorrectly, it can cause BASIC or the operating system to fail. See Also DEF SEG; PEEK; VARPTR, VARSEG; VARPTR$ Example See the DEF SEG statement programming example, which uses the POKE statement.